package IC.lir.instructions;
import IC.lir.*;
import java.util.List;

import IC.lir.operands.*;

import util.Pair;

/**
 * 
 * VirtualCall R1.R2( arg=val, arg=val ), R3
 * 
 * Call method in R1 DispatchVector, offset R2, return to R3
 * 
 */
public class VirtualCallInstr extends CallInstr {
	private RegOperand object;
	private ImmOperand method;

	/**
	 * create a virtual call instruction
	 * @param object object pointer
	 * @param method method offset
	 * @param args call arguments 
	 */
	public VirtualCallInstr(RegOperand object, ImmOperand method, 
			List<Pair<String, Operand>> args, RegOperand dest) {
		super(args,dest);
		this.object = object;
		this.method = method;
	}

	/**
	 * @return the method offset
	 */
	public ImmOperand getMethod() {
		return method;
	}

	/**
	 * @return the object pointer
	 */
	public RegOperand getObject() {
		return object;
	}

	/**
	 * accept a visitor
	 */
	public <D,U> U accept(Visitor<D,U> v, D context) {
		return v.visit(this,context);
	}
}
